import VueRouter from "vue-router";
import Home from "../pages/Home";
import Login from "../pages/Login";
import Adimin from "../pages/Adimin";
import Register from "../pages/Register";
import My from "../pages/My";

const routers = new VueRouter({
  mode: "hash",
  // mode: 'history',
  routes: [
    {
      path: "",
      name: "Login",
      component: Login,
      meta: {
        keepAlive: true,
      },
    },
    {
      path: "/home",
      name: "home",
      component: Home,
      meta: {
        keepAlive: true,
      },
      children: [
        {
          path: "my",
          name: "my",
          component: My,
          meta: {
            keepAlive: true,
          },
        },
      ],
    },
    {
      path: "/Adimin",
      name: "Adimin",
      component: Adimin,
      meta: {
        keepAlive: false,
      },
    },
    {
      path: "/Register",
      name: "register",
      component: Register,
      meta: {
        keepAlive: true,
      },
    },
  ],
});

routers.beforeEach((to, from, next) => {
  next(); // 允许此次路由跳转
});
export default routers;
